<?php

// ========================== 文件说明 ==========================//
// 本文件说明：附件输出
// --------------------------------------------------------------//
// 本程序作者：angel
// --------------------------------------------------------------//
// 本程序版本：SaBlog-X Ver 1.6
// --------------------------------------------------------------//
// 本程序主页：http://www.sablog.net
// ========================== 开发环境 ==========================//
// register_globals = Off
// --------------------------------------------------------------//
// magic_quotes_gpc = On
// --------------------------------------------------------------//
// safe_mode = On
// --------------------------------------------------------------//
// Windows server 2003 & Linux & FreeBSD
// --------------------------------------------------------------//
// Apache/1.3.33 & PHP/4.3.2 & MySQL/4.0.17
// --------------------------------------------------------------//
// Apache/1.3.34 & PHP/4.4.1 & MySQL/5.0.16
// --------------------------------------------------------------//
// Apache/2.0.55 & PHP/5.1.1 & MySQL/5.0.15
// --------------------------------------------------------------//
// Copyright (C) Security Angel Team All Rights Reserved.
// ==============================================================//


// 加载前台常用函数

require_once('config.php');

// 去除转义字符
function sax_stripslashes($array) {
	if (is_array($array)) {
		foreach ($array as $k => $v) {
			$array[$k] = sax_stripslashes($v);
		}
	} else if (is_string($array)) {
		$array = stripslashes($array);
	}
	return $array;
}


// 查询文章

$attachmentid = intval($_GET['id']);

mysql_query("UPDATE summerpractise SET down = '1' WHERE id = '$attachmentid'");

$attachinfo = mysql_fetch_array(mysql_query("SELECT * FROM summerpractise WHERE id='$attachmentid'"));


$filepath = '/home/content/domains/content.org.cn/public_html/summerpractise/uploads/'.$attachinfo['attach'];

if(is_readable($filepath)) {
	ob_end_clean();

	header('Cache-control: max-age=31536000');

	header('Expires: ' . gmdate('D, d M Y H:i:s',time()+31536000) . ' GMT');

	header('Last-Modified: ' . gmdate('D, d M Y H:i:s',time()) . ' GMT');
	header('Content-Encoding: none');
	header('Content-type: application/msword');
	header('Content-Disposition: attachment; filename='.urlencode($attachinfo['level']).'_'.urlencode($attachinfo['team']).'_'.urlencode($attachinfo['master']).'_'.urlencode($attachinfo['id']).'.doc');
	header('Content-Length: '.filesize($filepath));
	error_reporting(0);
	readfile($filepath);
	flush();
	ob_flush();
	exit;

} else {
	message('读取附件失败', './');
}

?>